//
// Unihan Input Method
//
// Copyright © 2002-2007 Sun Wah Linux Ltd.
//
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
// USA
//
// $Id: cands_factory.h 757 2007-05-10 08:19:31Z roger $
//

#ifndef _CANDS_FACTORY_H
#define _CANDS_FACTORY_H

#include "frequence.h"

#define CF_PREEDIT_MAX_LEN 50

typedef struct _InputCell {
	char *cell;
	struct _InputCell *next;
} InputCell;

typedef struct _MultiCandPos {
	InputCell *inputCell;
	InputCell *lastInputCell;
	int lowIdx;
	int highIdx;
	int exactIdx;
	int numCands;
	int numExactCands;
	char preedit[CF_PREEDIT_MAX_LEN];
	int preeditLen;
	struct _MultiCandPos *next;
} MultiCandPos;

typedef struct _CandFactory {
	MultiCandPos *multiCandPos;
	FreqCandList *freqCandList;
	int luCurrCandOffset;
	int numMultiCandPos;
	int numTotalCands;
	char keys[CF_PREEDIT_MAX_LEN];
	char *word;
} CandFactory;

void CF_append_InputCell(InputCell **ic, char *cell);
void CF_free_InputCell(InputCell *inputCell);
void CF_intergrate_cells_to_preedit(MultiCandPos *multiCandPos);

void CF_all_throw_a_key(CandFactory *candFactory);
void CF_all_throw_a_InputCell(CandFactory *candFactory);

MultiCandPos *CF_append_MultiCandPos(MultiCandPos *mcp);
void CF_free_MultiCandPos(MultiCandPos *multiCandPos);
int CF_double_MultiCandPos(CandFactory *candFactory);
int CF_half_MultiCandPos(CandFactory *candFactory);
void CF_display_tree(CandFactory *candFactory);

void CF_erase_keys(CandFactory *candFactory);
void CF_erase_keys_with_cell(CandFactory *candFactory, char *now, char *other);
void CF_set_the_last_InputCell_to_keys(CandFactory *candFactory);

void CF_clear_CandFactory(CandFactory *candFactory);

int CF_get_cand_idx_by_id(CandFactory *candFactory, int id);

#endif /* _CANDS_FACTORY_H */

// vi:ts=4:nowrap:cin:expandtab
